package com.zhx.ad.common.advice;

import com.zhx.ad.common.exception.AdException;
import com.zhx.ad.common.vo.CommonResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 *describe: 全局异常处理
 *
 *@author zhanghaixuan
 *@date 2019/02/01
 **/
@RestControllerAdvice
public class GlobalExceptionAdvice {

	@ExceptionHandler(value = AdException.class)
	public CommonResponse<String> handlerAdException(HttpServletRequest request, AdException exception) {
		CommonResponse<String> commonResponse = new CommonResponse<String>(-1,"business error");
		commonResponse.setData(exception.getMessage());
		return commonResponse;
	}
}
